#include <vtkForceDirectedLayoutStrategy.h>
#include <vtkGraphLayoutView.h>
#include <vtkMutableUndirectedGraph.h>
#include <vtkNamedColors.h>
#include <vtkNew.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>

#include <vtkArcSource.h>
#include <vtkPolyDataMapper.h>
#include "vtkPolygon.h"
#include "vtkProperty.h"

#include "vtkLookupTable.h"
#include "vtkMinimalStandardRandomSequence.h"
#include "vtkCellData.h"
#include "vtkSphereSource.h"
#include "vtkTubeFilter.h"
#include "vtkLineSource.h"
#include "vtkSphereSource.h"
#include <vtkProperty.h>
#include "vtkCamera.h"
#include "vtkCameraActor.h"
#include "vtkAppendPolyData.h"
#include "vtkPointCloudFilter.h"
#include "vtkPointSource.h"

#include "vtkInteractorStyleTrackballCamera.h"


int main(int, char*[]) {


    vtkNew<vtkNamedColors> colors;


//    std::array<unsigned char, 4> bkg{{26, 51, 102, 255}};
//    colors->SetColor("BkgColor", bkg.data());

    vtkNew<vtkAppendPolyData> appendFilter;


    for (int i = 0; i < 1000; ++i) {
        vtkNew<vtkSphereSource> sphere;
        sphere->SetPhiResolution(8);
        sphere->SetThetaResolution(8);
        sphere->SetRadius(1);
        sphere->SetCenter(i, 0, 0);
        sphere->Update();

        vtkNew<vtkPointSource> point;
        point->SetNumberOfPoints(1);
        point->SetCenter(i, 2, 0);
        point->SetRadius(1);
        appendFilter->AddInputData(point->GetOutput());

        appendFilter->AddInputData(sphere->GetOutput());
    }

//    vtkCleanPolyData

    appendFilter->Update();

    vtkNew<vtkPolyDataMapper> sphereMapper;
    sphereMapper->SetInputConnection(appendFilter->GetOutputPort());


//    vtkNew<vtkPolyDataMapper> sphereMapper;
//    sphereMapper->SetInputConnection(sphere->GetOutputPort());

    vtkNew<vtkActor> actor;
    actor->SetMapper(sphereMapper);
    actor->GetProperty()->SetColor(
            colors->GetColor4d("red").GetData());
//  cylinderActor->RotateX(30.0);
//  cylinderActor->RotateY(-45.0);



    vtkNew<vtkRenderer> renderer;
//    renderer->SetBackground(colors->GetColor3d("BkgColor").GetData());
    renderer->ResetCamera();
    renderer->GetActiveCamera()->Zoom(1.5);
    renderer->GetActiveCamera()->SetPosition(0, 0, 400);

    renderer->AddActor(actor);

//    renderer->AddActor(cylinderActor->ShallowCopy());

    vtkNew<vtkRenderWindow> renderWindow;
    renderWindow->SetSize(300, 300);
    renderWindow->AddRenderer(renderer);
    renderWindow->SetWindowName("Cylinder");

    vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
    renderWindowInteractor->SetRenderWindow(renderWindow);

    renderWindow->Render();
    renderWindowInteractor->Start();

    return EXIT_SUCCESS;
}